﻿<Controls:SinacorWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
    xmlns:Custom="http://schemas.xceed.com/wpf/xaml/datagrid"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
	  xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls"
    WindowStartupLocation="CenterScreen" 
    AutoContentHeight="True" 
    AutoContentWidth="True"
    WindowState="Maximized" 
    Title="{DynamicResource Bovespa.Corretagem.Label.CadastroFormadorMercado}"
	  x:Class="Sinacor.UI.Bovespa.Corretagem.View.SmartClient.CadastroFormadorMercado"
    ModulePlus="False"
    ModuleId="ORD">
    <Controls:SinacorExpanderContainer x:Name="ExcFormadorMercado"
                                     VerticalAlignment="Stretch">
        <Controls:SinacorExpanderContainer.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="4" />
            <RowDefinition Height="*"/>
        </Controls:SinacorExpanderContainer.RowDefinitions>
        <Controls:SinacorExpander Header="{DynamicResource Bovespa.Corretagem.Label.Pesquisa}"
                                  Grid.Row="0"
                                  x:Name="ExpPesquisar"
                                  IsExpanded="True">
            <Grid>
                <Controls:SinacorLabel HorizontalAlignment="Left"
                                       Width="100"
                                       Content="{DynamicResource Bovespa.Corretagem.Label.Cliente}"
                                       Margin="0,0,0,0"
                                       x:Name="LblPesquisaCliente" HorizontalContentAlignment="Left"/>
                <Controls:SinacorTextBox HorizontalAlignment="Left"
                                         Text="{Binding FiltroFormadorMercado.ApelidoCliente, UpdateSourceTrigger=PropertyChanged}"
                                         VerticalAlignment="Top"
                                         Margin="0,20,0,0"
                                         Width="180" 
                                         TabIndex="1" 
                                         MaxLength="20" 
                                         x:Name="txtFiltroApelido" 
                                         LostFocus="txtFiltroApelido_LostFocus"
                                         PreviewLostKeyboardFocus="txtFiltroApelido_PreviewLostKeyboardFocus"/>
                <Controls:SinacorButton Icon="IconButtonClient" 
                                        x:Name="BtnCliente" 
                                        IsEnabled="true" 
                                        Margin="184,20,0,0" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top" 
                                        TabIndex="2" 
                                        Click="BtnCliente_Click"
                                        ToolTip="{DynamicResource Bovespa.Corretagem.Label.PesquisarCliente}"/>
                <Controls:SinacorLabel HorizontalAlignment="Left" 
                                       x:Name="LblPesquisaAtivo" 
                                       Width="50" 
                                       Content="{DynamicResource Bovespa.Corretagem.Label.Ativo}" 
                                       Margin="210,0,0,0"
                                       HorizontalContentAlignment="Left"/>
                <Controls:SinacorTextBox Width="75" 
                                         Text="{Binding FiltroFormadorMercado.Ativo, UpdateSourceTrigger=PropertyChanged}" 
                                         VerticalAlignment="Top" 
                                         HorizontalAlignment="Left" 
                                         Margin="210,20,0,0" 
                                         TabIndex="3" 
                                         MaxLength="5" 
                                         x:Name="txtFiltroAtivo"/>
                <Controls:SinacorButton Icon="IconButtonSearch" 
                                        x:Name="BtnAtivo" 
                                        IsEnabled="true" 
                                        Margin="289,20,0,0" 
                                        HorizontalAlignment="Left" 
                                        TabIndex="4" 
                                        VerticalAlignment="Top" 
                                        OnBufferedClick="BtnAtivo_Click"
                                        ToolTip="{DynamicResource Bovespa.Corretagem.Tooltip.PesquisarAtivo}"/>
                <Controls:SinacorLabel HorizontalAlignment="Left"
                                       Width="80"
                                       Content="{DynamicResource Bovespa.Corretagem.Label.ISIN}"
                                       Margin="316,0,0,0" HorizontalContentAlignment="Left"
                                       />
                <Controls:SinacorTextBox Text="{Binding FiltroFormadorMercado.Isin, UpdateSourceTrigger=PropertyChanged}" 
                                         VerticalAlignment="Top"
                                         Margin="316,20,0,0"
                                         Width="115" 
                                         TabIndex="5" 
                                         MaxLength="12"
										 HorizontalAlignment="Left"                                          
                                         x:Name="txtFiltroIsin"/>
                <Controls:SinacorLabel
                                       Width="40"
                                       Content="{DynamicResource Bovespa.Corretagem.Label.Desc}"
                                       Margin="435,0,0,0" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
                                       />
                <Controls:SinacorDecimalTextBox Value="{Binding FiltroFormadorMercado.PercentualDesconto, UpdateSourceTrigger=PropertyChanged}" 
                                         HorizontalAlignment="Left"
                                         VerticalAlignment="Top"
                                         Margin="435,20,0,0"
                                         Width="40" 
                                         TabIndex="6" 
                                         MaxLength="2"
                                            Decimals="2"
                                            Integers="5"
                                            IsReadOnly="False"
                                            AcceptsNegative="False"
                                         x:Name="txtDesc"/>
                <Controls:SinacorLabel
                                       Width="140"
                                       Content="{DynamicResource Bovespa.Corretagem.Label.Mercado}"
                                       Margin="479,0,0,0" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
                                       />
                <Controls:SinacorComboBox x:Name="cmbTipoMercado"
                                         VerticalAlignment="Top"
                                         Margin="479,20,0,0"
                                         Width="165" 
                                         TabIndex="7"
										 HorizontalAlignment="Left"
										 WidthPopup="250"                                         
                                         DisplayMemberPath="Text"
                                         SelectedValuePath="Value"
                                         ItemsSource="{Binding Path=ColecaoTipoMercado}"
                                         SelectionChanged="cmbTipoMercado_SelectionChanged">

                </Controls:SinacorComboBox>
                <Controls:SinacorLabel Width="85" 
                                       x:Name="LblDataInicio"
                                       Content="{DynamicResource Bovespa.Corretagem.Label.DataDeInicio}" 
                                       HorizontalAlignment="Left" 
                                       Margin="648,0,0,0" HorizontalContentAlignment="Left"/>
                <Controls:SinacorDatePicker x:Name="DtpDataInicio" 
                                            HorizontalAlignment="Left" 
                                            Value="{Binding FiltroFormadorMercado.DataInicial, UpdateSourceTrigger=PropertyChanged}" 
                                            Margin="648,20,0,0" 
                                            VerticalAlignment="Top" 
                                            TabIndex="8"/>
                <Controls:SinacorLabel Width="72" 
                                       x:Name="LblDataFim"
                                       Content="{DynamicResource Bovespa.Corretagem.Label.DataDeFim}" 
                                       Margin="757,0,0,0" 
                                       HorizontalAlignment="Left" HorizontalContentAlignment="Left"/>
                <Controls:SinacorDatePicker HorizontalAlignment="Left" 
                                            x:Name="DtpDataFim"
                                            Value="{Binding FiltroFormadorMercado.DataFinal, UpdateSourceTrigger=PropertyChanged}" 
                                            Margin="757,20,0,0" 
                                            VerticalAlignment="Top" 
                                            TabIndex="9"/>
                <Controls:SinacorButton Content="{DynamicResource Bovespa.Corretagem.Label.Pesquisar}" 
                                        x:Name="BtnPesquisar"
                                        Width="80" 
                                        Margin="866,20,0,0" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top" 
                                        TabIndex="10" 
                                        Click="btnPesquisar_Click"
                                        IsDefault="True"/>
                <Controls:SinacorButton Icon="IconButtonNewSearch" 
                                        x:Name="BtnNovaPesquisa" 
                                        IsEnabled="true" 
                                        Margin="950,20,0,0" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top" 
                                        TabIndex="11" 
                                        Click="btnNovaPesquisa_Click"/>
            </Grid>
        </Controls:SinacorExpander>
        <Controls:SinacorExpander Header="{DynamicResource Bovespa.Corretagem.Label.FormadoresMercado}" 
                                  Grid.Row="2" 
                                  x:Name="ExpFormadorMercado" 
                                  IsExpanded="True" AllowExpand="False">
            <Grid>
                <Controls:SinacorDataGrid x:Name="dtgFormadorMercado" 
                                          Margin="0,0,0,0" 
                                          IsSynchronizedWithCurrentItem="True" 
                                          ItemsSource="{Binding Path=ListaFormadorMercado}" 
                                          AllowBeginInsert="True" 
                                          AllowBeginUpdate="True" 
                                          AllowDelete="True" 
                                          EndingInsert="dtgFormadorMercado_EndingInsert" 
                                          EndingUpdate="dtgFormadorMercado_EndingUpdate" 
                                          Deleting="dtgFormadorMercado_Deleting" 
                                          SelectionMode="Single" 
                                          CurrentCellChanged="dtgFormadorMercado_CurrentCellChanged"
                                          Inserted="dtgFormadorMercado_Inserted">
                    <Controls:SinacorDataGrid.Columns>
                        <Controls:Column Name="Cliente"
                                         Title="Bovespa.Corretagem.Label.Cliente"
                                         IsRequired="True"
                                         AllowInsert="True"
                                         AllowUpdate="False"
                                         HorizontalCellAlignment="Left"
                                         DisplayMemberPath="ApelidoCliente"
						                 AutoAdjustWidthToContent="False"
										 Width="70"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox
                                      Text="{Binding ApelidoCliente, UpdateSourceTrigger=PropertyChanged}"
                                      x:Name="txtApelidoCliente"
                                      MaxLength="20"
                                      IsRequired="False" PreviewKeyDown="txtApelidoCliente_PreviewKeyDown">
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="Ativo"
                                        Title="Bovespa.Corretagem.Label.Ativo"
                                        IsRequired="True"
                                        AllowInsert="True"
                                        AllowUpdate="False"
                                        HorizontalCellAlignment="Center"
                                        DisplayMemberPath="Ativo"
										AutoAdjustWidthToContent="False"
										Width="60"
                                        CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox
                                      Text="{Binding Ativo, UpdateSourceTrigger=PropertyChanged}"
                                      x:Name="txtAtivo"
                                      MaxLength="5"
                                      IsRequired="False" PreviewKeyDown="txtAtivo_PreviewKeyDown">
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- ISIN -->
                        <Controls:Column Name="ISIN"
                                        Title="Bovespa.Corretagem.Label.ISIN"
                                        IsRequired="True"
                                        AllowInsert="False"
                                        AllowUpdate="False"                                         
                                        HorizontalCellAlignment="Center"
                                        DisplayMemberPath="Isin"
										AutoAdjustWidthToContent="False"
										Width="110" />

                        <!-- Tipo Mercado -->
                        <Controls:Column Name="Mercado"
                                         Title="Bovespa.Corretagem.Label.Mercado"                                         
                                         AllowInsert="True"
                                         AllowUpdate="False"                                         
                                         DisplayMemberPath="TipoMercado"
										 AutoAdjustWidthToContent="False"
										 Width="110"
                                         HorizontalCellAlignment="Center"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">

                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorComboBox Name="cboTipoMercado"                                                                                                                             
                                                              ItemsSource="{Binding Path=PresenterCadastroFormadorMercado.ColecaoTipoMercado, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}" 
                                                              SelectedValue="{Binding TipoMercado}"
                                                              IsRequired="True"
                                                              Width="100"
                                                              />

                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>


                        <!-- Data Inicio -->
                        <Controls:Column Name="Inicio"
                                         Title="Bovespa.Corretagem.Label.DataDeInicio"
                                         IsRequired="True"
                                         AllowInsert="True"
                                         AllowUpdate="False"
                                         HorizontalCellAlignment="Center" 
                                         DisplayMemberPath="DataInicial"
										 AutoAdjustWidthToContent="False"
										 Width="110" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDatePicker Name="DtpDataInicial"
                                              Value="{Binding DataInicial, UpdateSourceTrigger=PropertyChanged}"
                                              IsRequired="False">
                                    </Controls:SinacorDatePicker>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="Fim"
                                        Title="Bovespa.Corretagem.Label.DataDeFim"
                                        IsRequired="True"
                                        AllowInsert="True"
                                        AllowUpdate="False"
                                        HorizontalCellAlignment="Center" 
                                        DisplayMemberPath="DataFinal"
										AutoAdjustWidthToContent="False"
										Width="110" 
                                        CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDatePicker
                                      Value="{Binding DataFinal, UpdateSourceTrigger=PropertyChanged}"
                                      x:Name="DtpDataFinal"
                                      IsRequired="False">
                                    </Controls:SinacorDatePicker>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="Desconto"
                                         Title="Bovespa.Corretagem.Label.Desconto"
                                         IsRequired="True"
                                         Integers="3"
                                         Decimals="3"
                                         AllowInsert="True"
                                         AllowUpdate="True"
										 AutoAdjustWidthToContent="False"
										 Width="90" 
                                         HorizontalCellAlignment="Right"
                                         DisplayMemberPath="PercentualDesconto"
                                         StringFormat="n3"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox
                                        Value="{Binding PercentualDesconto, UpdateSourceTrigger=PropertyChanged}"
                                        x:Name="txtPercentualDesconto"
                                        Integers="3"
                                        Decimals="3"
                                        IsChangeMonitored="True"
                                        IsFormated="True"
                                        IsRequired="False"
                                        AcceptsNegative="False">
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                    </Controls:SinacorDataGrid.Columns>
                </Controls:SinacorDataGrid>
            </Grid>
        </Controls:SinacorExpander>
    </Controls:SinacorExpanderContainer>
</Controls:SinacorWindow>